package city.spring.controller.mealService;

import com.baomidou.mybatisplus.extension.api.ApiController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/recipes")
public class RecipesController extends ApiController {

//    /**
//     * <strong></strong> Service
//     */
//    private final RecipesService recipesService;
//    private final FoodInfoService foodInfoService;
//    /**
//     * 实体类（）可排序字段
//     */
//    private final List<SFunction<RecipesEntity, ?>> entityOrderFields;
//
//    public RecipesController(RecipesService recipesService, FoodInfoService foodInfoService) {
//        this.recipesService = recipesService;
//        this.foodInfoService = foodInfoService;
//        this.entityOrderFields = new ArrayList<>();
//    }
//
//    /**
//     * 获取全部的 <strong></strong> 列表
//     */
//    @GetMapping("all")
//    public Object listAll(@PageableDefault(sort = {"gmtCreate"}) Pageable pageable, RecipesEntity entity) {
//        LambdaQueryChainWrapper<RecipesEntity> lambdaQuery = buildLambdaQuery(entity);
//        MyBatisUtils.lambdaQueryAddOrder(lambdaQuery, pageable, entityOrderFields);
//        return success(lambdaQuery.list());
//    }
//
//    /**
//     * 分页获取 <strong></strong> 列表
//     *
//     * @param pageable 分页参数信息
//     */
//    @GetMapping
//    public Object list(@PageableDefault(sort = {"gmtCreate"}) Pageable pageable, RecipesEntity entity) {
//        LambdaQueryChainWrapper<RecipesEntity> lambdaQuery = buildLambdaQuery(entity);
//        MyBatisUtils.lambdaQueryAddOrder(lambdaQuery, pageable, entityOrderFields);
//        Page<RecipesEntity> page = lambdaQuery.page(MyBatisUtils.toPage(pageable, false));
//        return success(page);
//    }
//
//    /**
//     * 获取一个 <strong></strong>
//     *
//     * @param id 主键ID
//     */
//    @GetMapping("{id}")
//    public Object info(@PathVariable String id) {
//        RecipesEntity entity = recipesService.getById(id);
//        recipesService.loadMealTime(entity);
//        recipesService.loadDisease(entity);
//        return success(entity);
//    }
//
//    /**
//     * 获取带有可用食品菜单的食谱信息
//     */
//    @GetMapping("/menu/{id}")
//    public Object foodTypeMenuInfo(@PathVariable String id) {
//        RecipesEntity entity = recipesService.getById(id);
//        recipesService.loadDisease(entity);
//        Map<String, List<FoodInfoEntity>> foodInfo = recipesService.loadTypeFoodInfo(entity);
//        return success(foodInfo);
//    }
//
//    /**
//     * 更新带有可用食品菜单的食谱信息
//     */
//    @PutMapping("/menu/{id}")
//    public Object updateFoodMenu(@PathVariable String id, @RequestBody List<String> idList) {
//        recipesService.updateRecipesMenu(id, idList);
//        return new ResponseEntity<>(HttpStatus.OK);
//    }
//
//    /**
//     * 更新食谱的餐次信息
//     */
//    @PutMapping("/meal/{id}")
//    public Object updateFoodMeal(@PathVariable String id, @RequestBody RecipesEntity entity) {
//        entity.setId(id);
//        recipesService.updateRecipesMealTime(entity);
//        return new ResponseEntity<>(HttpStatus.OK);
//    }
//
//    /**
//     * 添加一个 <strong></strong>
//     *
//     * @param entity 新增的信息
//     */
//    @PostMapping
//    public Object add(@RequestBody RecipesEntity entity) {
//        recipesService.saveRecipes(entity);
//        HttpHeaders headers = new HttpHeaders();
//        headers.add(HttpHeaders.LOCATION, entity.getId());
//        return new ResponseEntity<>(headers, HttpStatus.CREATED);
//    }
//
//    /**
//     * 修改一个 <strong></strong>
//     *
//     * @param id     主键ID
//     * @param entity 修改后的信息
//     */
//    @PutMapping("{id}")
//    public Object update(@PathVariable String id, @RequestBody RecipesEntity entity) {
//        entity.setId(id);
//        recipesService.updateRecipes(entity);
//        recipesService.updateRecipesMealTime(entity);
//        return new ResponseEntity<>(HttpStatus.OK);
//    }
//
//    /**
//     * 删除一个 <strong></strong>
//     *
//     * @param id 主键ID
//     */
//    @DeleteMapping("{id}")
//    public Object delete(@PathVariable String id) {
//        recipesService.removeById(id);
//        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
//    }
//
//    /**
//     * 删除多个 <strong></strong>
//     *
//     * @param ids 主键ID列表
//     */
//    @DeleteMapping
//    public Object deleteIds(@RequestBody List<String> ids) {
//        recipesService.removeByIds(ids);
//        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
//    }
//
//    /**
//     * 构建查询条件内容
//     *
//     * @param entity 实体对象： <strong></strong>
//     * @return lambda query chain wrapper
//     */
//    private LambdaQueryChainWrapper<RecipesEntity> buildLambdaQuery(RecipesEntity entity) {
//        LambdaQueryChainWrapper<RecipesEntity> lambdaQuery = recipesService.lambdaQuery();
//        lambdaQuery.eq(StringUtils.isNotBlank(entity.getId()), RecipesEntity::getId, entity.getId());
//        return lambdaQuery;
//    }

}
